package tools

import "time"

const (
	DateFormat = "2006-01-02 15:04:05"
)

// GetCurrentTime 获取当前时间
func GetCurrentTime() time.Time {
	return time.Now()
}

// FormatTime 格式化时间为字符串
func FormatTime(t time.Time) string {
	return t.Format(DateFormat)
}

// ParseTime 解析字符串为时间
func ParseTime(timeStr string) (time.Time, error) {
	return time.Parse(DateFormat, timeStr)
}

// AddTime 时间加减运算
func AddTime(t time.Time, duration time.Duration) time.Time {
	return t.Add(duration)
}

// CalculateDuration 计算时间差
func CalculateDuration(startTime, endTime time.Time) time.Duration {
	return endTime.Sub(startTime)
}

// 计算时间差
//startTime := time.Date(2023, time.September, 7, 10, 0, 0, 0, time.UTC)
//endTime := time.Date(2023, time.September, 7, 12, 0, 0, 0, time.UTC)
//duration := tools.CalculateDuration(startTime, endTime)
